/*
 * @Author: sxb
 * @Email: sxb@mail.com
 * @Date: 2020-02-20 13:23:34
 * @Descripttion: 
 */
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';

import { Observable } from "rxjs"

@Injectable({
  providedIn: 'root'
})
export class ReturnproductManageService {
  
  // 出入库：采购单表管理
  // 获取所有的Po号
  getAllPocodes(): Observable<any> {
    return this.http.get("/api/po/getAllPocodes", {}).pipe()
  }
  
  // 出入库：接受入库明细管理
  getReceiveInfosByPo(data): Observable<any> {
    let _dataJson = {
        params: {
            ...data
        }
    }
    return this.http.get("/api/receiveInfo/getReceiveInfosByPo", _dataJson)
  }
  
  // 出入库：退换货管理
  getReturnChange(data): Observable<any> {
    return this.http.get("/api/returnchange", {params: { ...data }});
  }
  postCreatelist(data) : Observable<any>{
    return this.http.post("/api/returnchange/createlist", data).pipe()
  }
  delReturnchange(data): Observable<any>{
    return this.http.delete("/api/returnchange/delete", {params: { ...data }}).pipe()
  }
  
  // 出入库：退换货明细管理
  private retChangeDetail = "/api/returnchangeDetail";  
  getReturnChangeDetail(data): Observable<any> {
    return this.http.get(this.retChangeDetail, {params: { ...data }});
  }  
  putReturnChangeDetail(data): Observable<any> {
    return this.http.put(this.retChangeDetail, data).pipe()
  }
  putBackDetail(data): Observable<any> {
    return this.http.put("/api/returnchangeDetail/backdetail?id="+data.id, {});
  }  
  putCheckstCorage(data): Observable<any> {
    return this.http.put("/api/returnchangeDetail/checkstorage?id="+ data.id +"&isexpedited="+data.isexpedited, {});
  }
  postConfirmstorage(data): Observable<any> {
    return this.http.post("/api/returnchangeDetail/confirmstorage", data);
  }
  delReturnChangeDetail(data){
    return this.http.delete("/api/returnchangeDetail/delete", {params: { ...data }}).pipe()
  }
  /**
   * @Author: sxb
   * @Email: sxb@mail.com
   * @Date: 2020-03-31 14:56:43
   * @UseComponent: 
   * @Descripttion: 根据退换货明细Id获取详情
   * @Return: 
   */
  postFindById(data): Observable<any>{
    return this.http.get("/api/returnchangeDetail/findById?id="+ data.id, {}).pipe()
  }

  constructor(
    private http:HttpClient
    ) { }
}
